/* Code for the paper "A Randomized Controlled Design Reveals Barriers to Citizenship for Low-Income Immigrants" */

** NOTE: 
** this public data release is a deidentified version of the data where 
** the covariates age, HH income per capita, and years on green card are binned into quartiles to protect the privacy of participants
** the original analysis presented in the study and SM was run with exact age, HH income per capita, and years on green card
** therefore, the results with this deidentified data will only approximately replicate those results that use covariates 
** to request access to the exact variables please contact: jhain@stanford.edu

*** Set location of data and location for output

global data_location   = ""
global output_location = ""


*** Load in the replication data set
cd "$data_location"
use nny_replication_data_deidentified, clear

** two samples
* ouctome = "registered"   for registrants who participated in voucher lottery
* ouctome = "regfeewaiver" for registrants who participated in nudge experiment


* generating weights for the voucher regression based on randomization blocks 
egen pij = mean(winner) , by(ocblock)
gen  weight = (1/pij) * winner + (1/(1-pij))*(1-winner)


*** Creating tables 

* set output location
cd "$output_location"


*** Table S1: Descriptive Statistics for Sample of Voucher Study *

* descriptive stats

global covars1 = "submitted hhinc_cap yrs_greencard age gender_f"
global covars2 = "origin_DR origin_Ecuador origin_Colombia"
global covars3 = "marital_married marital_single"
global covars4 = "educ_HS educ_somecollege educ_BA"
global covars5 = "lang_Eng lang_Span"
global covars6 = "winner any_voucher"
global covars7 = "treat_Control treat_Letter treat_SMSLetter treat_MetroLetter treat_CallsAppoint treat_MultiCalls"

cap file close myfile
file open myfile using descriptVoucher.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{Descriptive Statistics for Sample of Voucher Study (N=863)}\label{tab:desvoucher}" _n
$WRITE "    \begin{tabular}{lcc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Mean & SD    \\" _n
$WRITE "\hline" _n
foreach dv of varlist $covars1  {
sum `dv'  if outcome == "registered"
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  " `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 )  " \\" _n
}

$WRITE "Origin: \\" _n
foreach dv of varlist $covars2  {
sum `dv'  if outcome == "registered"
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  "$\,$ `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 )  " \\" _n
}

$WRITE "Marital Status: \\" _n
foreach dv of varlist $covars3  {
sum `dv'  if outcome == "registered"
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  "$\,$ `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 )  " \\" _n
}

$WRITE "Highest Education: \\" _n
foreach dv of varlist $covars4  {
sum `dv'  if outcome == "registered"
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  "$\,$ `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 )  " \\" _n
}

$WRITE "Language for Registration: \\" _n
foreach dv of varlist $covars5  {
sum `dv'  if outcome == "registered"
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  "$\,$ `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 )  " \\" _n
}

$WRITE "Treatment Received: \\" _n
foreach dv of varlist $covars6 {
summarize `dv' if outcome == "registered"
global Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo: variable label `dv'
$WRITE "$\,$ `foo' & " %9.2f ( $rmean1) " & " %9.2f ( $rsd1 ) " \\ " _n
}


$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{3}{p{0.6\textwidth}}{\scriptsize \emph{Note}: Sample consists of legal permanent residents who registered for the naturalization program and have a household income between 150 and 300 percent of the Federal Poverty Guidelines and receive no means-tested benefits.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile

cap file close myfile


*** Table S2: Descriptive Statistics for Sample of Nudge Study*

file open myfile using descriptNudge.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{Descriptive Statistics for Sample of Nudge Study (N=1,760)}\label{tab:desnudge}" _n
$WRITE "    \begin{tabular}{lcc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Mean & SD    \\" _n
$WRITE "\hline" _n

foreach dv of varlist $covars1  {
sum `dv'  if outcome == "regfeewaiver"
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  " `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 )  " \\" _n
}

$WRITE "Origin: \\" _n
foreach dv of varlist $covars2  {
sum `dv'  if outcome == "regfeewaiver"
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  "$\,$ `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 )  " \\" _n
}

$WRITE "Marital Status: \\" _n
foreach dv of varlist $covars3  {
sum `dv'  if outcome == "regfeewaiver"
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  "$\,$ `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 )  " \\" _n
}

$WRITE "Highest Education: \\" _n
foreach dv of varlist $covars4  {
sum `dv'  if outcome == "regfeewaiver"
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  "$\,$ `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 )  " \\" _n
}

$WRITE "Language for Registration: \\" _n
foreach dv of varlist $covars5  {
sum `dv'  if outcome == "regfeewaiver"
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  "$\,$ `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 )  " \\" _n
}

levelsof treatfw, local(levels)

$WRITE "Treatment Received: \\" _n
foreach dv of varlist $covars7 {
sum `dv'  if outcome == "regfeewaiver"
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  "$\,$ `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 )  " \\" _n
}


$WRITE "\hline" _n

$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{3}{p{0.6\textwidth}}{\scriptsize \emph{Note}: Sample consists of legal permanent residents who registered for the naturalization program and are potentially eligible for the federal fee waiver since their household income is below 150 percent of the Federal Poverty Guidelines or they receive means-tested benefits.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile


*** Table S3: Descriptive Statistics for Origin Groups


/// detailed origin distribution

* descriptive stats

global covars2 = "origin_DR origin_Ecuador origin_Colombia origin_Jamaica origin_China origin_Mexico origin_Guyana origin_Haiti origin_Honduras origin_Peru origin_TrinidadAndTobago origin_ElSalvador origin_Panama origin_Guatemala origin_Russia"

cap file close myfile
file open myfile using descriptOrigin.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{Descriptive Statistics for Origin Groups}\label{tab:desorigin}" _n
$WRITE "    \begin{tabular}{lcccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    \multicolumn{2}{c}{Voucher Study} & \multicolumn{2}{c}{Nudge Study}   \\" _n
$WRITE "          &    Mean & SD & Mean & SD    \\" _n
$WRITE "\hline" _n


$WRITE "Origin: \\" _n
foreach dv of varlist $covars2  {
sum `dv'  if outcome == "registered"
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'

sum `dv'  if outcome == "regfeewaiver"
global  Obs2 = `r(N)'
global rmean2 = `r(mean)'
global rsd2 = `r(sd)'

$WRITE  "$\,$ `foo' & "  %9.3f ( $rmean1 ) " & " %9.3f ( $rsd1 ) " & "  %9.3f ( $rmean2 ) " & " %9.3f ( $rsd2 )  " \\" _n
}
$WRITE "    \hline " _n
$WRITE "     N     &    \multicolumn{2}{c}{N=863} & \multicolumn{2}{c}{1,760}   \\" _n

$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{5}{p{0.6\textwidth}}{\scriptsize \emph{Note}: Sample consists of legal permanent residents who registered for the naturalization program.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile


*** Table S4: Balance Checks for Voucher Study *

global nudge_covars = "treat_Letter treat_SMSLetter treat_MetroLetter treat_CallsAppoint treat_MultiCalls"
global covars = "hhinc_cap yrs_greencard age gender_f origin_DR origin_Ecuador origin_Colombia marital_married marital_single educ_HS educ_somecollege educ_BA lang_Eng lang_Span"

eststo clear

eststo: reg winner $covars [aweight=weight]     , robust , if outcome=="registered"
test $covars
estadd scalar p=r(p)

eststo: reg winner $covars [aweight=weight]     , robust , if outcome=="registered" & submitted!=.
test $covars
estadd scalar p=r(p)

eststo: reg any_voucher $covars [aweight=weight]     , robust , if outcome=="registered"
test $covars
estadd scalar p=r(p)

eststo: reg any_voucher $covars [aweight=weight]     , robust , if outcome=="registered" & submitted!=.
test $covars
estadd scalar p=r(p)

esttab * using balcheckVoucher.tex, varlabels(_cons Constant) label ar2 scalar("F F-value" "p P-value") ///
 cells(b(fmt(%9.3f)) se(par)) noomitted  nomtitle collabels(none) nobaselevels  varwidth(50) replace ///
 mgroups("Voucher Offer (Initial Lottery)" "Voucher Offer (Both Lotteries)", pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
 title(Balance Checks for Voucher Study \label{balcheckVoucher}) ///
 postfoot( ///
 \hline  ///
 \multicolumn{4}{p{6.2in}}{\scriptsize ///
 \emph{Note}: Regression coefficients shown with robust standard errors in parentheses. ///
 F-values and P-values in the bottom rows are from omnibus F tests against the null that all slope coefficients are jointly equal to zero. ///
 Models 1 and 3 refer to the samples of all participants; models 2 and 4 to the samples of participants who responded to the follow-up survey.} ///
 \end{tabular} ///
 \end{table} ///
 )

*** Table S5: Balance Checks for Nudge Study (All Participants)  * 

eststo clear
eststo: mlogit treatfw $covars , robust , if outcome=="regfeewaiver" 
test $covars

estadd scalar chi = r(chi2)
estadd scalar pp = r(p)


esttab * using balcheckNudge1.tex, unstack varlabels(_cons Constant) label pr2 scalars("chi Chi-Square" "pp P-value") ///
 cells(b(fmt(%9.3f)) se(par)) nonumbers noomitted  nomtitle collabels(none) nobaselevels  varwidth(50) replace ///
  mgroups("Treatment Groups:", pattern(1 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
 title(Balance Checks for Nudge Study (All Participants) \label{balcheckNudge1}) eqlabels("Letter" "Letter+SMS" "Letter+Metro" "Calls Appt" "Multi Calls Appt") ///
 postfoot( ///
 \hline  ///
 \multicolumn{6}{p{6.2in}}{\scriptsize ///
 \emph{Note}: Multinomial logit regression coefficients shown with robust standard errors in parentheses. The reference category is participants in the control group that received no additional nudge. ///
 Chi-Square and P-value in the bottom rows are from an omnibus Chi-Square test against the null that all slope coefficients are jointly equal to zero. ///
 This model is based on the sample of all participants.} ///
 \end{tabular} ///
 \end{table} ///
 )
 
*** Table S6: Balance Checks for Nudge Study (Responders) * 
 
eststo clear
eststo: mlogit treatfw $covars , robust , if outcome=="regfeewaiver" & submitted!=.
test $covars
estadd scalar pp = r(p)
estadd scalar chi = r(chi2)


esttab * using balcheckNudge2.tex, unstack varlabels(_cons Constant) label pr2 scalar("chi Chi-Square" "pp P-value") ///
 cells(b(fmt(%9.3f)) se(par)) nonumbers noomitted  nomtitle collabels(none) nobaselevels  varwidth(50) replace ///
  mgroups("Treatment Groups:", pattern(1 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
 title(Balance Checks for Nudge Study (Responders to follow-up survey) \label{balcheckNudge2}) eqlabels("Letter" "Letter+SMS" "Letter+Metro" "Calls Appt" "Multi Calls Appt") ///
 postfoot( ///
 \hline  ///
 \multicolumn{6}{p{6.2in}}{\scriptsize ///
 \emph{Note}: Multinomial logit regression coefficients shown with robust standard errors in parentheses. The reference category are participants in the control group that received no additional nudge. ///
 Chi-Square and P-value in the bottom rows are from an omnibus Chi-Square test against the null that all slope coefficients are jointly equal to zero. ///
 This model is based on the samples of all participants who responded to the follow-up survey.} ///
 \end{tabular} ///
 \end{table} ///
 )

 
*** Table S7: Survey Response Checks for Voucher Group * 
 
* compute interactions 
foreach x of global covars {
gen XX`x' = any_voucher*`x'
local foo : variable label `x'
label var XX`x' "Voucher \$\times\$ `foo'"
}


foreach x of global covars {
gen ZZ`x' = winner*`x'
local foo : variable label `x'
label var ZZ`x' "Winner \$\times\$ `foo'"
}
 
eststo clear

* model 1
eststo: reg replied any_voucher  [aweight=weight], robust , if outcome=="registered" 
estadd local covars "No"
testparm any_voucher
estadd scalar pp = r(p)
estadd scalar pf = r(F)

* model 2
eststo: reg replied any_voucher $covars XX* [aweight=weight], robust , if outcome=="registered" 
estadd local covars "Yes"
testparm any_voucher XX*
estadd scalar pp = r(p)
estadd scalar pf = r(F)

* model 3
eststo: ivregress 2sls  replied (any_voucher=winner)  [aweight=weight]     , robust , if outcome=="registered"
estadd local covars "No"
testparm any_voucher
estadd scalar pp = r(p)
estadd scalar pchi = r(chi2)

* model 4
eststo: ivregress 2sls  replied (any_voucher XX* = winner ZZ* ) $covars [aweight=weight]     , robust , if outcome=="registered"
estadd local covars "Yes"
testparm any_voucher XX*
estadd scalar pp = r(p)
estadd scalar pchi = r(chi2)

esttab * using replyVoucher.tex, varlabels(_cons Constant) label prehead( ///
\begin{table}[htbp]\centering \tiny ///
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} ///
\caption{Survey Response Checks for Voucher Group \label{replyVoucher}} ///
\begin{tabular}{l*{4}{c}} ///
\hline \hline ) ///
 cells(b(fmt(%9.3f)) se(par)) noomitted  nomtitle collabels(none) nobaselevels  varwidth(50) replace ///
 mgroups("Responded to Survey", pattern(1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) stats(covars N r2_a pf pchi pp, fmt(2 "" 0 "" 3) label("Covariates" "Observations" "Adusted R$^2$" "F-value" "Chi-Square" "P-value"))  ///
 title(Survey Response Checks for Voucher Group \label{replyVoucher}) ///
 postfoot( ///
 \hline  ///
 \multicolumn{5}{p{3.75in}}{\tiny ///
 \emph{Note}: Regression coefficients shown with robust standard errors in parentheses. ///
 Models 1 and 2 regress whether a participant responded to the survey on the indicator for whether participants won in the lotteries and were thus offered the voucher plus all interactions of this indiciator with the covariates. ///
 Models 3 and 4 are instrumental variable regressions where the indicator for whether participants were offered the voucher is instrumented by an indicator for whether they won the initial lottery. For Model 4 the interactions  ///
between the covariates and the treatment are also instrumented by the interactions between the winning in the initial lottery and the covariates. ///
 The F-test for Model 3 tests the null that the coefficients on the treatement and the coefficients on the interactions of the covariates with the treatment are jointly equal to zero. The Chi-Square test for Model 4 is also a joint ///
 significance test against the null that the coefficients on the treatment and the interactions of the covariates with the treatment are jointly equal to zero.} ///
 \end{tabular} ///
 \end{table} ///
 )
 
 
*** Table S8: Survey Response Checks for Fee Waiver Group  * 

eststo clear

*model 1
eststo: reg replied $nudge_covars, robust, if outcome == "regfeewaiver"
estadd local covars "No"
test $nudge_covars
estadd scalar pp=r(p)
estadd scalar ff = r(F)


*model 2
eststo: reg replied $nudge_covars $covars, robust, if outcome == "regfeewaiver"
estadd local covars "Yes"
test $nudge_covars
estadd scalar pp=r(p)
estadd scalar ff = r(F)

esttab * using replyNudge.tex, varlabels(_cons Constant) label prehead( ///
\begin{table}[htbp]\centering \footnotesize ///
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} ///
\caption{Survey Response Checks for Fee Waiver Group \label{replyNudge}} ///
\begin{tabular}{l*{2}{c}} ///
\hline \hline ) ///
 cells(b(fmt(%9.3f)) se(par)) noomitted  nomtitle collabels(none) nobaselevels  varwidth(50) replace ///
 mgroups("Responded to Survey", pattern(1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) stats(covars N r2_a ff pp,fmt(2 "" 0 "" 3) labels("Covariates" "Observations" "Adusted R$^2$" "F-value" "P-value"))  ///
 title(Survey Response Checks for Nudge Group \label{replyNudge}) ///
 postfoot( ///
 \hline  ///
 \multicolumn{3}{p{4.2in}}{\scriptsize ///
 \emph{Note}: Regression coefficients shown with robust standard errors in parentheses. ///
 Model 1 regresses whether a participant responded to the survey on the nudge group assignment indicators (the control group that received no additional nudge is the reference category). ///
 Model 2 adds covariates. ///
 The F-test is against the null that the regression coeffificients on the nudge group assignment indicators are jointly equal to null. } ///
 \end{tabular} ///
 \end{table} ///
 )


 
/* Effect Estimate Regressions */

*** Table S9: Intention-to-treat Effect Estimates for Voucher Study *

eststo clear

* model 1
eststo: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" 
estadd local covars "No"
mat n1 = e(N)

* save stats for R figure
capture matrix drop res
* control mean
lincom _cons*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Control"
mat res = nullmat(res) \ res1

* treatment mean
lincom (_cons + any_voucher)*100 
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Treated"
mat res = nullmat(res) \ res1

* delta
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Effect 1"
mat res = nullmat(res) \ res1

* model 2
eststo: reg submitted any_voucher $covars [aweight=weight], robust , if outcome=="registered" 
estadd local covars "Yes"

* delta 2
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Effect 2"
mat res = nullmat(res) \ res1

* model 3
eststo: ivregress 2sls  submitted (any_voucher=winner)  [aweight=weight]     , robust , if outcome=="registered"
estadd local covars "No"

* model 4
eststo: ivregress 2sls  submitted (any_voucher=winner) $covars [aweight=weight]     , robust , if outcome=="registered"
estadd local covars "Yes"

matrix colnames res = "pe" "se"
mat2txt, matrix(res) saving("vouchereffects.txt") replace

esttab * using effectsVoucher.tex, varlabels(_cons Constant) label ///
 cells(b(fmt(%9.3f)) se(par)) noomitted  nomtitle collabels(none) nobaselevels  varwidth(50) replace ///
 mgroups("Applied for Naturalization", pattern(1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) stats(covars N,fmt(2 "" 0) label("Covariates" "Observations"))  ///
 title(Intention-to-treat Effect Estimates for Voucher Study \label{effectsVoucher}) ///
 postfoot( ///
 \hline  ///
 \multicolumn{5}{p{4.2in}}{\scriptsize ///
 \emph{Note}: Regression coefficients shown with robust standard errors in parentheses. ///
 Models 1 and 2 regress the outcome on the indicator for whether participants won in the lotteries and were thus offered the voucher. ///
 Models 3 and 4 are instrumental variable regressions where the indicator for whether participants were offered the voucher is intsrumented by an indicator for whether they won the initial lottery.} ///
 \end{tabular} ///
 \end{table} ///
 )
 

**** Table S11: Intention-to-treat Effect Estimates for Voucher Study by Subsample
 
eststo clear

* model 1

*gender subsample

foreach i of numlist 0 1 {
eststo: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & gender_f == `i'
if `i' == 0 {
estadd local modelname = "Male" 
}
if `i' == 1{
estadd local modelname = "Female"
}


mat n1 = `e(N)'

lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Gender `i'" 
mat res = nullmat(res) \ res1
}

*education subsample

gen HSorless = educ < 6
foreach i of numlist 0 1 {
eststo: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & HSorless == `i'

if `i' == 1 {
estadd local modelname = "High School" 
}
if `i' == 0{
estadd local modelname = "College"
}

mat n1 = `e(N)'

lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "HS `i'" 
mat res = nullmat(res) \ res1

}


* language subsample

eststo: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & lang_Eng == 1
estadd local modelname = "English"
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Survey Eng" 
mat res = nullmat(res) \ res1

eststo: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & lang_Span == 1
estadd local modelname = "Spanish"
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Survey Spanish" 
mat res = nullmat(res) \ res1

matlist res


*hhinc subsample
gen hhinc_capCat = hhinc_cap>3
* test for dif
reg submitted any_voucher##hhinc_capCat  [aweight=weight], robust , if outcome=="registered" 


foreach i of numlist 0 1 {
eststo: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & hhinc_capCat == `i'

if `i' == 0 {
estadd local modelname = "Low income" 
}
if `i' == 1{
estadd local modelname = "High income"
}
mat n1 = `e(N)'

lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "HHInc `i'" 
mat res = nullmat(res) \ res1
}

* age subsample

sum age if outcome=="registered" & submitted!=., det 
gen ageCat = age>2
foreach i of numlist 0 1 {
eststo: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & ageCat == `i'

if `i' == 0 {
estadd local modelname = "Younger" 
}
if `i' == 1{
estadd local modelname = "Older"
}
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Age `i'" 
mat res = nullmat(res) \ res1
}

matlist res

* origin subsample

eststo: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & origin_DR == 1
estadd local modelname = "Dominican Republic"
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Dominican Republic" 
mat res = nullmat(res) \ res1

eststo: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & origin_Ecuador == 1
estadd local modelname = "Ecuador"
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Ecuador" 
mat res = nullmat(res) \ res1

eststo: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & origin_Colombia == 1
estadd local modelname = "Colombia"
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Colombia" 
mat res = nullmat(res) \ res1


matlist res
matrix colnames res = "pe" "se" "N"
mat2txt, matrix(res) saving("vouchereffects.txt") replace

* table 1 of 2 for subsample
esttab * using subsampleVoucher.tex, varlabels(_cons Constant) nomtitles label ///
 cells(b(fmt(%9.3f)) se(par)) noomitted  collabels(none) nobaselevels  varwidth(50) replace ///
 mgroups("Applied for Naturalization", pattern(1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) stats(N modelname,fmt(0) label("Observations" "Subsample"))  ///
 title(Intention-to-treat Effect Estimates for Voucher Study by Subsample \label{effectsVoucherSub}) ///
 postfoot( ///
 \hline  ///
 \multicolumn{14}{p{8.5in}}{\scriptsize ///
 \emph{Note}: Regression coefficients shown with robust standard errors in parentheses. ///
 Model 1 is the subsample of respondents that are males. ///
 Model 2 is the subsample of respondents that are females. ///
 Model 3 is the subsample of respondents that received a high school education or less. ///
 Model 4 is the subsample of respondents that received at least some college education. ///
 Model 5 is the subsample of respondents that registered for the program using an English-language version of the registration. ///
 Model 6 is the subsample of respondents that registered for the program using a Spanish-language version of the registration.  ///
 Model 7 is the subsample of respondents that are at or below the median household income of \\$18,051. ///
 Model 8 is the subsample of respondents that are above the median household income of \\$18,051. ///
 Model 9 is the subsample of respondents that are at or below the median age of 40. ///
 Model 10 is the subsample of respondents that are above the median age of 40. ///
 Model 11 is the subsample of respondents that are from the Domenican Republic. ///
 Model 12 is the subsample of respondents that are from Ecuador. ///
 Model 13 is the subsample of respondents that are from Colombia.  } ///
 \end{tabular} ///
 \end{table} ///
 )
*/



*** Table S12: Effect Considering Eligibility for a Partial Fee Waiver in December 2016

eststo clear

* model 1
eststo: reg submitted any_voucher [aweight=weight], robust , if vouchertype == "partial"
estadd local covars "No"
estadd local vtype "Yes"

* model 2
eststo: reg submitted any_voucher $covars [aweight=weight], robust , if vouchertype == "partial" 
estadd local covars "Yes"
estadd local vtype "Yes"

* model 3
eststo: reg  submitted any_voucher [aweight=weight]     , robust , if vouchertype == "full"
estadd local covars "No"
estadd local vtype "No"

* model 4
eststo: reg   submitted any_voucher $covars [aweight=weight]     , robust , if vouchertype=="full"
estadd local covars "Yes"
estadd local vtype "No"

esttab * using effectsVoucherType.tex, varlabels(_cons Constant) label ///
 cells(b(fmt(%9.3f)) se(par)) noomitted  nomtitle collabels(none) nobaselevels  varwidth(50) replace ///
 mgroups("Applied for Naturalization", pattern(1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) stats(vtype covars N,fmt(2 "" 0) label("Eligible for a Partial Fee Waiver" "Covariates" "Observations"))  ///
 title(Effect Considering Eligibility for a Partial Fee Waiver in December 2016 \label{effectsVoucherType}) ///
 postfoot( ///
 \hline  ///
 \multicolumn{5}{p{4.5in}}{\scriptsize ///
 \emph{Note}: Regression coefficients shown with robust standard errors in parentheses. ///
 Models 1 and 2  show the effect of receiving a voucher for participants that would have been eligible for a partial fee waiver beginning on December 23, 2016. ///
 Models 3 and 4  show the effect of receiving a voucher for participants that were not eligible for a partial fee waiver beginning on December 23, 2016. } ///
 \end{tabular} ///
 \end{table} ///
 )



*** Table S10: Intention to treat Effect Estimates for Nudge Study 

eststo clear

*model 1 (no covariates)
eststo: reg submitted $nudge_covars, robust, if outcome == "regfeewaiver"
estadd local covars "No"

* save stats for R figure
capture matrix drop res

* control mean
lincom _cons*100
mat res1 = r(estimate) , r(se)
mat rownames res1 = "Control"
mat res = nullmat(res) \ res1

* treatment means
foreach x of global nudge_covars {
lincom (_cons + `x')*100
mat res1 = r(estimate) , r(se)
mat rownames res1 = "`x'"
mat res = nullmat(res) \ res1
matlist res
}

* treatment effects
foreach x of global nudge_covars {
lincom `x'*100
mat res1 = r(estimate) , r(se)
mat rownames res1 = "delta `x'"
mat res = nullmat(res) \ res1
matlist res
}

matrix colnames res = "pe" "se"
mat2txt, matrix(res) saving("nudgeeffects.txt") replace


*model 2 (covariates adjusted)
eststo: reg submitted $nudge_covars $covars, robust, if outcome == "regfeewaiver"
estadd local covars "Yes"

esttab * using effectsNudge.tex, varlabels(_cons Constant) label prehead( ///
\begin{table}[htbp]\centering \footnotesize ///
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} ///
\caption{Intention-to-treat Effect Estimates for Nudge Study \label{effectsNudge}} ///
\begin{tabular}{l*{2}{c}} ///
\hline \hline ) //////
 cells(b(fmt(%9.3f)) se(par)) noomitted  nomtitle collabels(none) nobaselevels  varwidth(50) replace ///
 mgroups("Applied for Naturalization", pattern(1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) stats(covars N,fmt(2 "" 0) label("Covariates" "Observations"))  ///
 title(Intention-to-treat Effect Estimates for Nudge Study \label{effectsNudge}) ///
 postfoot( ///
 \hline  ///
 \multicolumn{3}{p{4.2in}}{\scriptsize ///
 \emph{Note}: Regression coefficients shown with robust standard errors in parentheses. ///
 Models 1 and 2 regress the outcome on indicators for whether participants were assigned to the various nudge groups (the control group that received no additional nudge is the reference category). ///
 } ///
 \end{tabular} ///
 \end{table} ///
 )
 


*** Table S13: Intention-to-treat Effect Estimates for Nudge Study by Subsample

* adding asteriks to a nudge treatment to indicate small sample size
label var treat_MultiCalls "Mixed-outreach Strategy$^\star$"
eststo clear


* gender subsample
foreach i of numlist 0 1 {
eststo: reg submitted $nudge_covars , robust , if outcome=="regfeewaiver" & gender_f == `i'
if `i' == 0 {
estadd local modelname = "Male" 
}
if `i' == 1{
estadd local modelname = "Female"
}
tab treat_MultiCalls if outcome=="regfeewaiver" & gender_f == `i'

}

* education subsample
foreach i of numlist 0 1 {
eststo: reg submitted $nudge_covars , robust , if outcome=="regfeewaiver" & HSorless == `i'
if `i' == 1 {
estadd local modelname = "High School" 
}
if `i' == 0{
estadd local modelname = "College"
}
tab treat_MultiCalls if outcome=="regfeewaiver" & HSorless == `i'

}

* language subsample
eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & lang_Eng == 1
estadd local modelname = "English"
tab treat_MultiCalls if outcome=="regfeewaiver" & lang_Eng == 1

eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & lang_Span == 1
estadd local modelname = "Spanish"
tab treat_MultiCalls if outcome=="regfeewaiver" & lang_Span == 1


*hhinc subsample
sum hhinc_cap if outcome=="regfeewaiver" & submitted!=., det
cap drop hhinc_capCat
gen hhinc_capCat = hhinc_cap>1
foreach i of numlist 0 1 {
eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & hhinc_capCat == `i'
if `i' == 0 {
estadd local modelname = "Low income" 
}
if `i' == 1{
estadd local modelname = "High income"
}
tab treat_MultiCalls if outcome=="regfeewaiver" & hhinc_capCat == `i'

}

* age subsample
sum age if outcome=="regfeewaiver" & submitted!=., det
cap drop ageCat
gen ageCat = age>2

foreach i of numlist 0 1 {
eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & ageCat == `i'
if `i' == 0 {
estadd local modelname = "Younger" 
}
if `i' == 1{
estadd local modelname = "Older"
}
tab treat_MultiCalls if outcome=="regfeewaiver" & ageCat == `i'
}

* origin subsample
eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & origin_DR == 1
tab treat_MultiCalls if outcome=="regfeewaiver" & origin_DR == 1
estadd local modelname = "Dominican Republic"



* table 1 of 2 for subsample
esttab * using subsampleNudge.tex, varlabels(_cons Constant) nomtitles label ///
 cells(b(fmt(%9.3f)) se(par)) noomitted  collabels(none) nobaselevels  varwidth(50) replace ///
 mgroups("Applied for Naturalization", pattern(1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) stats(N modelname,fmt(0) label("Observations" "Subsample"))  ///
 title(Intention-to-treat Effect Estimates for Nudge Study by Subsample \label{effectsNudgeSub}) ///
 postfoot( ///
 \hline  ///
 \multicolumn{12}{p{7.5in}}{\scriptsize ///
 \emph{Note}: Regression coefficients shown with robust standard errors in parentheses. ///
 Model 1 is the subsample of respondents that are males. ///
 Model 2 is the subsample of respondents that are females. ///
 Model 3 is the subsample of respondents that received a high school education or less. ///
 Model 4 is the subsample of respondents that received at least some college education. ///
 Model 5 is the subsample of respondents that registered for the program using an English-language version of the registration. ///
 Model 6 is the subsample of respondents that registered for the program using a Spanish-language version of the registration.  ///
 Model 7 is the subsample of respondents that are at or below the median household income of \\$6,500. ///
 Model 8 is the subsample of respondents that are above the median household income of \\$6,500. ///
 Model 9 is the subsample of respondents that are at or below the median age of 36. ///
 Model 10 is the subsample of respondents that are above the median age of 36. ///
 Model 11 is the subsample of respondents that are from the Dominican Republic.$^\star$ Estimate  ///
 based on small sample size given the small size of the mixed-outreach group.} ///
 \end{tabular} ///
 \end{table} ///
 )
*/




*** Table S14: Intention-to-treat Effect Estimates for Nudge Study by Subsample
** Nudge Subsample 2 (Proxy for Business)
 
eststo clear 

eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & hhsize == 1
estadd local modelname = "HH Size: 1"

eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & hhsize == 2 
estadd local modelname = "HH Size: 2"

eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & hhsize >= 3  & hhsize!=.
estadd local modelname = "HH Size: $>$=3"

eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & marital_single == 1  
estadd local modelname = "Single"

eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & marital_married == 1  
estadd local modelname = "Married"


eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & ocdistance == 0 
estadd local modelname = "Low Distance"

eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & ocdistance == 1
estadd local modelname = "Medium Distance"

eststo: reg submitted $nudge_covars  , robust , if outcome=="regfeewaiver" & ocdistance == 2
estadd local modelname = "High Distance"


esttab * using subsampleNudgeBusy.tex, varlabels(_cons Constant) nomtitles label ///
 cells(b(fmt(%9.3f)) se(par)) noomitted  collabels(none) nobaselevels  varwidth(50) replace ///
 mgroups("Applied for Naturalization", pattern(1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) stats(N modelname,fmt(0) label("Observations" "Subsample"))  ///
 title(Intention-to-treat Effect Estimates for Nudge Study by Subsample \label{effectsNudgeSubBusy}) ///
 postfoot( ///
 \hline  ///
 \multicolumn{9}{p{6.5in}}{\scriptsize ///
 \emph{Note}: Regression coefficients shown with robust standard errors in parentheses. ///
 Models 1, 2, 3 are for the subsamples of respondents that have a household size of one, two, or three or more, respectively. ///
 Model 4 and 5 are for the subsamples of respondents that are single or married, respectively. ///
 Models 6, 7, and 8 are for the subsamples of respondents that live within a low, medium, or high distance ///
 to the closest Opportunity Center (distance groups were created based on equal-sized bins; the median distances by group are 1km, 2.6km, and 5.7km). $^\star$ Estimate  ///
 based on small sample size given the small size of the mixed-outreach group.} ///
 \end{tabular} ///
 \end{table} ///
 ) 
 
* relabeling varaiable, removing the asteriks from the previous table
label var treat_MultiCalls "Mixed-outreach Strategy"

 
/* ********************** */ 
** Multiple Imputation 

*** Table S15: Intention-to-treat Effect Estimates for Voucher Study (Multiple Imputation)

cd "$data_location"
use nny_replication_data_deidentified, clear 

* sorting by unique_id to ensure MI estimates are stable
sort unique_id 

* recalculating weights
egen pij = mean(winner) , by(ocblock)
gen  weight = (1/pij) * winner + (1/(1-pij))*(1-winner)

cd "$output_location"

keep if outcome=="registered"
global covars = "hhinc_cap yrs_greencard age gender_f origin_DR origin_Ecuador origin_Colombia marital_married marital_single educ_HS educ_somecollege educ_BA lang_Eng lang_Span"
keep $covars submitted outcome winner any_voucher weight outcome educ vouchertype

* multiple imputation
mi set flong 
mi xtset, clear
mi register imputed $covars submitted  winner any_voucher weight 
mi impute chained (pmm, knn(5)) $covars submitted winner any_voucher weight ,  add(10) rseed(42)

* fit models
eststo clear

* model 1
mi estimate, cmdok post: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" 
eststo
mat n1 = e(N)
estadd local covars "No"

* save stats for R figure
capture matrix drop res
* control mean
lincom _cons*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Control"
mat res = nullmat(res) \ res1
* treatment mean
lincom (_cons + any_voucher)*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Treated"
mat res = nullmat(res) \ res1

* delta
lincom any_voucher*100
mat res1 = r(estimate) , r(se)  , n1
mat rownames res1 = "Effect 1"
mat res = nullmat(res) \ res1

* model 2
mi estimate, cmdok post: reg submitted any_voucher $covars [aweight=weight], robust , if outcome=="registered"
eststo
estadd local covars "Yes"

* delta 2
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Effect 2"
mat res = nullmat(res) \ res1

* model 3
mi estimate, cmdok post: ivregress 2sls  submitted (any_voucher=winner)  [aweight=weight]     , robust , if outcome=="registered"
eststo
estadd local covars "No"

* model 4
mi estimate, cmdok post: ivregress 2sls  submitted (any_voucher=winner) $covars [aweight=weight]     , robust , if outcome=="registered"
eststo
estadd local covars "Yes"


esttab * using effectsVoucherMI.tex, varlabels(_cons Constant) label ///
 cells(b(fmt(%9.3f)) se(par)) noomitted  nomtitle collabels(none) nobaselevels  varwidth(50) replace ///
 mgroups("Applied for Naturalization", pattern(1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) stats(covars N,fmt(2 "" 0) label("Covariates" "Observations"))  ///
 title(Intention-to-treat Effect Estimates for Voucher Study (Multiple Imputation) \label{effectsVoucherMI}) ///
 postfoot( ///
 \hline  ///
 \multicolumn{5}{p{4.2in}}{\scriptsize ///
 \emph{Note}: Regression coefficients shown with robust standard errors in parentheses. ///
 Models 1 and 2 regress the outcome on the indicator for whether participants won in the lotteries and were thus offered the voucher. ///
 Models 3 and 4 are instrumental variable regressions where the indicator for whether participants were offered the voucher is instrumented ///
 by an indicator for whether they won the initial lottery. All analyses are based on multiple imputation using 10 imputed datasets. See text for details.     } ///
 \end{tabular} ///
 \end{table} ///
 )

** subgroup estimates
 
** voucher group
eststo clear

* model 1
foreach i of numlist 0 1 {
mi estimate, cmdok post: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & gender_f == `i'
eststo
mat n1 = `e(N)'

lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Gender `i'" 
mat res = nullmat(res) \ res1
}

gen HSorless = educ < 6
foreach i of numlist 0 1 {
mi estimate, cmdok post: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & HSorless != `i'
eststo
mat n1 = `e(N)'

lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "HS `i'" 
mat res = nullmat(res) \ res1

}


mi estimate, cmdok post: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & lang_Eng == 1
eststo
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Survey Eng" 
mat res = nullmat(res) \ res1

mi estimate, cmdok post: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & lang_Span == 1
eststo
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Survey Spanish" 
mat res = nullmat(res) \ res1

matlist res

* HH Income
gen hhinc_capCat = hhinc_cap>3
foreach i of numlist 0 1 {
mi estimate, cmdok post: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & hhinc_capCat == `i'
eststo
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "HHInc `i'" 
mat res = nullmat(res) \ res1
}


* age
gen ageCat = age>2
foreach i of numlist 0 1 {
mi estimate, cmdok post: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & ageCat == `i'
eststo
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Age `i'" 
mat res = nullmat(res) \ res1
}

matlist res

* origin group

mi estimate, cmdok post: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & origin_DR == 1
eststo
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Dominican Republic" 
mat res = nullmat(res) \ res1

mi estimate, cmdok post: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & origin_Ecuador == 1
eststo
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Ecuador" 
mat res = nullmat(res) \ res1

mi estimate, cmdok post: reg submitted any_voucher  [aweight=weight], robust , if outcome=="registered" & origin_Colombia == 1
eststo
mat n1 = `e(N)'
lincom any_voucher*100
mat res1 = r(estimate) , r(se) , n1
mat rownames res1 = "Colombia" 
mat res = nullmat(res) \ res1


matrix colnames res = "pe" "se" "N"
mat2txt, matrix(res) saving("vouchereffectsMI.txt") replace 
 
 
*** Table S16: Intention-to-treat Effect Estimates for Nudge Study (Multiple Imputation) 
 
cd "$data_location"
use nny_replication_data_deidentified, clear

* sorting by unique_id to ensure MI estimates are stable
sort unique_id 

cd "$output_location"

keep if outcome=="regfeewaiver"
global covars = "hhinc_cap yrs_greencard age gender_f origin_DR origin_Ecuador origin_Colombia marital_married marital_single educ_HS educ_somecollege educ_BA lang_Eng lang_Span"
keep $covars submitted outcome treat_* outcome

* multiple imputation
mi set flong 
mi xtset, clear
mi register imputed $covars submitted  $nudge_covars
mi impute chained (pmm, knn(5)) $covars submitted $nudge_covars ,  add(10) rseed(42)

eststo clear

*model 1
mi estimate, cmdok post: reg submitted $nudge_covars, robust, if outcome == "regfeewaiver"
eststo
estadd local covars "No"

* save stats for R figure
capture matrix drop res
* control mean
lincom _cons*100
mat res1 = r(estimate) , r(se)
mat rownames res1 = "Control"
mat res = nullmat(res) \ res1

foreach x of global nudge_covars {
lincom (_cons + `x')*100
mat res1 = r(estimate) , r(se)
mat rownames res1 = "`x'"
mat res = nullmat(res) \ res1
matlist res
}

foreach x of global nudge_covars {
lincom `x'*100
mat res1 = r(estimate) , r(se)
mat rownames res1 = "delta `x'"
mat res = nullmat(res) \ res1
matlist res
}

matrix colnames res = "pe" "se"
mat2txt, matrix(res) saving("nudgeeffectsMI.txt") replace

*model 2
mi estimate, cmdok post: reg submitted $nudge_covars $covars, robust, if outcome == "regfeewaiver"
eststo
estadd local covars "Yes"

esttab * using effectsNudgeMI.tex, varlabels(_cons Constant) label prehead( ///
\begin{table}[htbp]\centering \footnotesize ///
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} ///
\caption{Intention-to-treat Effect Estimates for Nudge Study (Multiple Imputation) \label{effectsNudgeMI}} ///
\begin{tabular}{l*{2}{c}} ///
\hline \hline ) /////////
 cells(b(fmt(%9.3f)) se(par)) noomitted  nomtitle collabels(none) nobaselevels  varwidth(50) replace ///
 mgroups("Applied for Naturalization", pattern(1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) stats(covars N,fmt(2 "" 0) label("Covariates" "Observations"))  ///
 title(Intention-to-treat Effect Estimates for Nudge Study (Multiple Imputation) \label{effectsNudgeMI}) ///
 postfoot( ///
 \hline  ///
 \multicolumn{3}{p{4.2in}}{\scriptsize ///
 \emph{Note}: Regression coefficients shown with robust standard errors in parentheses. ///
  Models 1 and 2 regress the outcome on indicators for whether participants were assigned to the various nudge groups (the control group that received no additional nudge is the reference category). ///
  All analyses are based on multiple imputation using 10 imputed datasets. See text for details.  } ///
 \end{tabular} ///
 \end{table} ///
 )
 

 
